<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<!--3、求一组数中的最大值和最小值，以及所在位置-->
	<body>
		<script>
			var arr = [20,30,45,95,84,75,32,10,90,80];
            var max = arr[0];
            var min = arr[0];
            var maxIndex = 0;
            var minIndex = 0;
            for (var i = 1; i < arr.length; i++) {
            if(arr[i] > max){
                max = arr[i];
                maxIndex = i+1;
            }
            if (arr[i] < min) {
                min = arr[i];
                minIndex = i+1;
            }
        }
        console.log("max="+max);
        console.log("maxIndex="+maxIndex);
        console.log("min="+min);
        console.log("minIndex="+minIndex);
		</script>
	</body>
</html>
